<template>
    <view class="uni-calendar-item__weeks-box" :class="{
        'uni-calendar-item--disable': weeks.disable,
        'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
        'uni-calendar-item--checked': (calendar.fullDate === weeks.fullDate && !weeks.isDay),
        'uni-calendar-item--multiple': weeks.multiple
    }" @click="choiceDate(weeks)">
        <view class="uni-calendar-item__weeks-box-item">
        	<view class="uni-calendar-item__weeks-box-item" v-if="selected && weeks.extraInfo">
        		<block v-if="newTime==weeks.fullDate&&calendar.fullDate!=weeks.fullDate">
		            <text class="uni-calendar-item__weeks-box-circless"></text>
		            <text class="uni-calendar-item__weeks-box-circleas"></text>
        		</block>
        		<block v-if="newTime!=weeks.fullDate&&calendar.fullDate!=weeks.fullDate">
		            <text class="uni-calendar-item__weeks-box-circle"></text>
		            <text class="uni-calendar-item__weeks-box-circlea"></text>
        		</block>
	            <text class="uni-calendar-item__weeks-box-texta">{{ weeks.date }}</text>
	            <!--<text v-if="weeks.extraInfo.info" class="uni-calendar-item__weeks-lunar_info">{{ weeks.extraInfo.info }}</text>-->
        	</view>
        	<view class="uni-calendar-item__weeks-box-item" v-else>
	            <text class="uni-calendar-item__weeks-box-text" :class="{
	                'uni-calendar-item--isDay-text': weeks.isDay,
	                'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
	                'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
	                'uni-calendar-item--multiple': weeks.multiple,
	                'uni-calendar-item--disable': weeks.disable,
	            }">{{ weeks.date }}</text>
	            <text v-if="newTime==weeks.fullDate" class="uni-calendar-item__weeks-lunar-text" :class="{
	                'uni-calendar-item--isDay-text': weeks.isDay,
	                'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
	                'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
	                'uni-calendar-item--multiple': weeks.multiple,
	            }">今天</text>
	            <text v-if="lunar && !weeks.extraInfo" class="uni-calendar-item__weeks-lunar-text" :class="{
	                'uni-calendar-item--isDay-text': weeks.isDay,
	                'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
	                'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
	                'uni-calendar-item--multiple': weeks.multiple,
	                'uni-calendar-item--disable': weeks.disable,
	            }">{{ weeks.isDay ? '今天' : (weeks.lunar.IDayCn === '初一' ? weeks.lunar.IMonthCn : weeks.lunar.IDayCn)
	}}</text>
	            <text v-if="weeks.extraInfo && weeks.extraInfo.info" class="uni-calendar-item__weeks-lunar-text" :class="{
	                'uni-calendar-item--extra': weeks.extraInfo.info,
	                'uni-calendar-item--isDay-text': weeks.isDay,
	                'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
	                'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
	                'uni-calendar-item--multiple': weeks.multiple,
	                'uni-calendar-item--disable': weeks.disable,
	            }">{{ weeks.extraInfo.info }}</text>
        	</view>
        </view>
    </view>
</template>

<script>
	import { formatDate } from '@/utils/utils'
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
export default {
    props: {
        weeks: {
            type: Object,
            default() {
                return {}
            }
        },
        calendar: {
            type: Object,
            default: () => {
                return {}
            }
        },
        selected: {
            type: Array,
            default: () => {
                return []
            }
        },
        lunar: {
            type: Boolean,
            default: false
        }
    },
    data() {
        return {
            newTime: formatDate(new Date(), 'YYYY-MM-DD')
        }
    },
    methods: {
        choiceDate(weeks) {
            this.$emit('change', weeks)
        }
    }
}
</script>

<style lang="scss" scoped>
.uni-calendar-item__weeks-box {
    flex: 1;
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.uni-calendar-item__weeks-lunar_info{
	position: absolute;
}

.uni-calendar-item__weeks-box-text {
    font-size: 28upx;
    color: #000;
}

.uni-calendar-item__weeks-lunar-text {
    font-size: 24upx;
    color: #007aff;
}
.uni-calendar-item__weeks-box-texta{
	font-size: 24upx;
    color: #fff;
    position: relative;
}

.uni-calendar-item__weeks-box-item {
    position: relative;
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100rpx;
    height: 100rpx;
}

.uni-calendar-item__weeks-box-circle {
    position: absolute;
    bottom: 2px;
    left: 50%;
    margin-left: -4px;
    width: 8px;
    height: 8px;
    border-radius: 8px;
    background: linear-gradient( 180deg, #CB9FFF 0%, #A28AFF 100%);
}
.uni-calendar-item__weeks-box-circless{
    position: absolute;
    bottom: 2px;
    left: 50%;
    margin-left: -4px;
    width: 8px;
    height: 8px;
    border-radius: 8px;
    background: #FDBA55;
}
.uni-calendar-item__weeks-box-circlea {
    position: absolute;
    top: 25rpx;
    left: 25rpx;
    width: 50rpx;
    height: 50rpx;
    border-radius: 50%;
    background: linear-gradient( 180deg, #CB9FFF 0%, #A28AFF 100%);
}
.uni-calendar-item__weeks-box-circleas {
    position: absolute;
    top: 25rpx;
    left: 25rpx;
    width: 50rpx;
    height: 50rpx;
    border-radius: 50%;
    background:#FDBA55;
}
.uni-calendar-item__weeks-box-circlea-checked{
	background: #007aff !important;
}
.uni-calendar-item__weeks-box-circlea-checkedss{
	background: #FDBA55 !important;
}


.uni-calendar-item--disable {
    background-color: rgba(249, 249, 249, 0.3);
    color: #868686;
}

.uni-calendar-item--isDay-text {
    color: #007aff;
}

.uni-calendar-item--isDay {
    background-color: #007aff;
    opacity: 0.8;
    color: #fff;
}

.uni-calendar-item--extra {
    color: #dd524d;
    opacity: 0.8;
}

.uni-calendar-item--checked {
    background-color: #007aff;
    color: #fff;
    opacity: 0.8;
}

.uni-calendar-item--multiple {
    background-color: #007aff;
    color: #fff;
    opacity: 0.8;
}
</style>
